﻿using System;
using System.Collections.Generic;
using SimpleFS.Core;
using SimpleFS.Core.Implementations;

namespace SimpleFS.Services.Journaling
{
    public class Directory : AbstractDirectory
    {
        protected IJournalingServiceProvider provider;

        public Directory(
            IDirectory target, IJournalingServiceProvider provider)
            : base(target)
        {
            this.provider = provider;
        }

        #region IDirectory Members

        public override IDirectory[] Directories
        {
            get { throw new NotImplementedException(); }
        }

        public override IFile[] Files
        {
            get { throw new NotImplementedException(); }
        }

        public override void Create()
        {
            this.provider.Write("Create directory {0}", base.internalObject.Name);
            base.internalObject.Create();
        }

        public override IDirectory GetDirectory(string directoryName)
        {
            this.provider.Write("Get directory {0}", directoryName);
            return base.internalObject.GetDirectory(directoryName);
        }

        public override IFile GetFile(string fileName)
        {
            this.provider.Write("Get file {0}", fileName);
            return base.internalObject.GetFile(fileName);
        }

        public override IFile AddFile(string fileName)
        {
            this.provider.Write("Add file {0}", fileName);
            return base.internalObject.AddFile(fileName);
        }

        public override IDirectory AddDirectory(string directoryName)
        {
            this.provider.Write("Add directory {0}", directoryName);
            return base.internalObject.AddDirectory(directoryName);
        }

        #endregion

        #region IFileSystemObject Members

        public override string Name
        {
            get
            {
                this.provider.Write("Name {0}", base.Name);
                return base.internalObject.Name;
            }
        }

        public override DateTime LastModifiedTime
        {
            get
            {
                this.provider.Write("Last modified time {0}", base.LastModifiedTime);
                return base.internalObject.LastModifiedTime;
            }
        }

        public override Dictionary<string, string> Attributes
        {
            get
            {
                this.provider.Write("Attributes {0}", base.Attributes);
                return base.internalObject.Attributes;
            }
        }

        public override IDirectory ParentDirectory
        {
            get { throw new NotImplementedException(); }
        }

        public void Copy(IFileSystemObject target)
        {
            this.provider.Write("Copy {0}", target.Name);
            base.internalObject.Copy(target);
        }

        public override void Move(IFileSystemObject target)
        {

        }

        public override void Delete()
        {
            throw new NotImplementedException();
        }

        public override bool Exists()
        {
            throw new NotImplementedException();
        }

        public override void Rename(string newName)
        {
            throw new NotImplementedException();
        }

        public override void Close()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
